package com.blast.cn.persenter.more

import android.app.Activity
import android.widget.SeekBar
import androidx.appcompat.widget.AppCompatSeekBar
import com.wxl.common.util.ScreenLightUtils
import com.wxl.common.viewmodel.AbsPresenter

class LightSeekPresenter : AbsPresenter() {

    var mCurrentScreenNum = 0

    override fun onCreated(vararg args: Any) {
        val seek = args[0] as AppCompatSeekBar
        mCurrentScreenNum = ScreenLightUtils.getScreenBrightness()
        seek.progress = mCurrentScreenNum / 51
        seek.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener{
            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
                mCurrentScreenNum = progress
                ScreenLightUtils.changSystemBrightness(mCurrentScreenNum * 51)
                ScreenLightUtils.setScreenBrightness(seek.context as Activity,mCurrentScreenNum * 51)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar?) {

            }

            override fun onStopTrackingTouch(seekBar: SeekBar?) {

            }
        })
    }
}